package com.xujie.chat.server.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class ExceptionHandler extends ChannelInboundHandlerAdapter {
	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
		if (cause instanceof java.io.IOException) {
			System.out.println("IOException occurred: " + cause.getMessage());
		} else {
			// 处理其他异常
			cause.printStackTrace();
		}
		// 关闭连接，释放资源
		ctx.close();
	}
}
